/*
 * 作者: 侯晓宇
 * 时间: 2017-02-06 
 * 说明：
 * Copyright (c) 2016-2017 中研沃兮
 */
define(function(require) {
	var p = {};
	var c = require('app/utils/CommonUtils');
	var tip = require('app/utils/TipUtils');
	
	p.launch = function(timestamp, callback_func) {
		var _timestamp = '';
//		yyyy-MM-dd HH:mm
		if(!c.isNullStr(timestamp)){
			_timestamp = c.timeFormat(timestamp); 
		}
		
		if (api.systemType == 'ios') {
			api.openPicker({
				type: 'date_time',
				date: _timestamp,
				title: '请选择日期与时间'
			}, function(ret, err) {
				var y = ret.year;
				var m = ret.month;
				var d = ret.day;
				var h = ret.hour;
				var min = ret.minute;
				
				if(!c.afterNow(y,m,d,h,min)){
					tip.show("开始时间应晚于当前时间");
					return;
				}
				callback_func(c.buildTimestamp(y,m,d,h,min));
				
			});
		} else {
			api.openPicker({
				type: 'date',
				title: '请选择日期'
			}, function(ret, err) {
				var y = ret.year;
				var m = ret.month;
				var d = ret.day;
				
				api.openPicker({
					type: 'time',
					title: '请选择时间'
				}, function(ret2, err) {

					var h = ret2.hour;
					var min = ret2.minute;
					if(!c.afterNow(y,m,d,h,min)){
						tip.show("开始时间应晚于当前时间");
						return;
					}
					callback_func(c.buildTimestamp(y,m,d,h,min));
				});
			});
		}


	}

	return p;
});